package com.itcast.springboot3x.controller;

import com.itcast.springboot3x.service.InitializerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping(value = "initializer")
public class InitializerController {
    @Autowired
    private InitializerService initializerService ;

    @GetMapping(value = "initializerTest")
    public Map<String, Object> initializerTest() {
        Map<String, Object> resultM = new HashMap<>() ;
        resultM.put("key1", initializerService.getApplicationContext().getEnvironment().getProperty("key1"));
        resultM.put("key2", initializerService.getApplicationContext().getEnvironment().getProperty("key2"));
        resultM.put("key3", initializerService.getApplicationContext().getEnvironment().getProperty("key3"));

        return resultM ;
    }
}
